package com.rui.single;

import java.util.ArrayList;
import java.util.List;

public enum EnumSingle {
    INSTANCE;

    public EnumSingle getInstance() {
        return INSTANCE;
    }
}

class Test {
    public static void main(String[] args) {
        EnumSingle instance1 = EnumSingle.INSTANCE;
        EnumSingle instance2 = EnumSingle.INSTANCE;

        System.out.println(instance1);
        System.out.println(instance2);

        System.out.println(instance1 == instance2);
    }
}

class Test2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();

        //遍历 list 中的每个元素
        for (String s : list) {
            System.out.println(s);
        }

        //输出 Hello World
        System.out.println("Hello World");

        //输出当前系统时间毫秒值
        System.out.println(System.currentTimeMillis());
    }

    //计算两个数的差值的方法
    public static int minus(int a, int b) {
        return a - b;
    }

    //计算两个数的积
    public static int multiply(int a, int b) {
        return a * b;
    }

    //判断一个年份是否是闰年
    public static boolean isLeapYear(int year) {
        return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
    }
}
